package polimi.sc.expoquest.storage.model;

import java.util.ArrayList;
import java.util.Collection;

/**
 * This class represents a single game in the application
 * @author Monica Lozano
 */
public class SingleGame {
	
	//----------------
	//CONSTANTS
	//----------------
	/**
	 * The types of sigle game provided
	 */
	public static final int TYPE_TRIVIA=0;
	public static final int TYPE_COMMENT=1;
	public static final int TYPE_CAMERA=2;
	//----------------
	//ATTRIBUTES
	//----------------
	/**
	 * ID in the database, this id is related to the _id column
	 * of the table, and this is automatically autoincremented
	 */
	private int id;
	/**
	 * The type of the single game, it SHOULD BE one of the constants defined
	 */
	private int type;
	
	/**
	 * The description of the game, for instance in the case of a trivia should be
	 * a question.
	 */
	private String description;
	
	/**
	 * If the game involves a picture that is need to be displayed, then
	 * that picture is saved in this attribute
	 */
	private String picURI;
	
	/**
	 * The maximum points that can be earned by the user when he/she is playing it
	 */
	private int maxPoints;
	
	/**
	 * The options available when the game is a TRIVIA game
	 */
	private Collection<GameOption> options;

	//----------------
	//CONSTRUCTOR
	//----------------
	
	public SingleGame(){}
	/**
	 * @param id:The id assigned by the android framework when the row is created
	 * @param type: TYPE_TRIVIA, TYPE_COMMENT,TYPE_CAMERA
	 * @param description: The question or the description of the game
	 * @param maxPoints: Maximum points that the user can earn by playing the game
	 */
	public SingleGame(int id,int type, String description, int maxPoints )
	{
		this.id = id;
		this.description= description;
		this.picURI= null;
		this.maxPoints= maxPoints;
		this.options = new ArrayList<GameOption>();
	}
	
	/**
	 * @param id:The id assigned by the android framework when the row is created
	 * @param type: TYPE_TRIVIA, TYPE_COMMENT,TYPE_CAMERA
	 * @param description: The question or the description of the game
	 * @param picURI: If make use of a picture
	 * @param maxPoints: Maximum points that the user can earn by playing the game
	 */
	public SingleGame(int id,int type, String description,String picURI, int maxPoints )
	{
		this.id = id;
		this.description= description;
		this.picURI= picURI;
		this.maxPoints= maxPoints;
		this.options = null;
	}

	/**
	 * Adds an option to the game</b>
	 * Precondition: The type of the game is TYPE_TRIVIA
	 * Postcondition: The option is added to the list of options of the game
	 * @param option: A option that should be added to the game
	 */
	public void addOption(GameOption option)
	{
		if(options == null)
			options = new ArrayList<GameOption>();	
		options.add(option);
	}
	
	//-------------------
	//GETTERS AND SETTERS
	//-------------------
	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return the type
	 */
	public int getType() {
		return type;
	}

	/**
	 * @param type the type to set
	 */
	public void setType(int type) {
		this.type = type;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the picURI
	 */
	public String getPicURI() {
		return picURI;
	}

	/**
	 * @param picURI the picURI to set
	 */
	public void setPicURI(String picURI) {
		this.picURI = picURI;
	}

	/**
	 * @return the maxPoints
	 */
	public int getMaxPoints() {
		return maxPoints;
	}

	/**
	 * @param maxPoints the maxPoints to set
	 */
	public void setMaxPoints(int maxPoints) {
		this.maxPoints = maxPoints;
	}

	/**
	 * @return the options
	 */
	public Collection<GameOption> getOptions() {
		return options;
	}

	/**
	 * @param options the options to set
	 */
	public void setOptions(Collection<GameOption> options) {
		this.options = options;
	}

}
